package com.ruoyi.vocational_college.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.vocational_college.domain.TbVocationalCollege;
import com.ruoyi.vocational_college.service.ITbVocationalCollegeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专科院校信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/vocational_college/vocational_college")
public class TbVocationalCollegeController extends BaseController
{
    @Autowired
    private ITbVocationalCollegeService tbVocationalCollegeService;

    /**
     * 查询专科院校信息列表
     */
    @PreAuthorize("@ss.hasPermi('vocational_college:vocational_college:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVocationalCollege tbVocationalCollege)
    {
        startPage();
        List<TbVocationalCollege> list = tbVocationalCollegeService.selectTbVocationalCollegeList(tbVocationalCollege);
        return getDataTable(list);
    }

    /**
     * 导出专科院校信息列表
     */
    @PreAuthorize("@ss.hasPermi('vocational_college:vocational_college:export')")
    @Log(title = "专科院校信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVocationalCollege tbVocationalCollege)
    {
        List<TbVocationalCollege> list = tbVocationalCollegeService.selectTbVocationalCollegeList(tbVocationalCollege);
        ExcelUtil<TbVocationalCollege> util = new ExcelUtil<TbVocationalCollege>(TbVocationalCollege.class);
        util.exportExcel(response, list, "专科院校信息数据");
    }

    /**
     * 获取专科院校信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('vocational_college:vocational_college:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbVocationalCollegeService.selectTbVocationalCollegeById(id));
    }

    /**
     * 新增专科院校信息
     */
    @PreAuthorize("@ss.hasPermi('vocational_college:vocational_college:add')")
    @Log(title = "专科院校信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVocationalCollege tbVocationalCollege)
    {
        return toAjax(tbVocationalCollegeService.insertTbVocationalCollege(tbVocationalCollege));
    }

    /**
     * 修改专科院校信息
     */
    @PreAuthorize("@ss.hasPermi('vocational_college:vocational_college:edit')")
    @Log(title = "专科院校信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVocationalCollege tbVocationalCollege)
    {
        return toAjax(tbVocationalCollegeService.updateTbVocationalCollege(tbVocationalCollege));
    }

    /**
     * 删除专科院校信息
     */
    @PreAuthorize("@ss.hasPermi('vocational_college:vocational_college:remove')")
    @Log(title = "专科院校信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbVocationalCollegeService.deleteTbVocationalCollegeByIds(ids));
    }
}
